package com.carkeeper.storebill.service.impl;

import com.carkeeper.storebill.dao.StoreBillLogMapper;
import com.carkeeper.storebill.pojo.StoreBillLog;
import com.carkeeper.storebill.service.StoreBillLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@Service
public class StoreBillLogServiceImpl implements StoreBillLogService {


    @Autowired
    StoreBillLogMapper storeBillLogMapper;

    /**
     * 根据账单id查询日志列表
     * @param billId
     * @return
     */
    @Override
    public List<StoreBillLog> findListByBillId(Integer billId) {

        Example example = new Example(StoreBillLog.class);
        Example.Criteria criteria = example.createCriteria();

        if (billId != null && billId > 0){

            criteria.andEqualTo("billId",billId);
        }

        List<StoreBillLog> storeBillLogs = storeBillLogMapper.selectByExample(example);
        return storeBillLogs;
    }

    @Override
    public int insertBillLog(StoreBillLog billLog) {

        if (billLog != null){

            return storeBillLogMapper.insertSelective(billLog);
        }

        return 0;
    }
}
